package com.jt.proxy;

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @outhor fufeixiang
 * @date 2021-04-25
 */
@Service("userService")
public class StaticProxy implements UserService {
    @Autowired
    private UserService userService;
    @Override
    public void userAdd(User user) {
        try {
            System.out.println("开启事务");
            userService.userAdd(user);
            System.out.println("结束事务");
        }catch (Exception e) {
            e.printStackTrace();
            System.out.println("事务回滚");
        }
    }

    @Override
    public void deleteUser(User user) {
        try {
            System.out.println("开启事务");
            userService.deleteUser(user);
            System.out.println("结束事务");
        }catch (Exception e) {
            e.printStackTrace();
            System.out.println("事务回滚");
        }
    }
}
